package com.bawei.caohao20240805.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.bawei.comm.model.bean.ChoBean
import com.bawei.comm.model.bean.KaiBean
import com.bawei.comm.model.bean.KanBean
import com.bawei.comm.model.bean.LiveBean
import com.bawei.comm.model.util.HttpUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.MultipartBody
import retrofit2.http.Header
import retrofit2.http.Part
import retrofit2.http.Query

/**
 * 作者: 曹浩
 * 时间: 2024/8/5
 * 功能描述:
 */
class ZhiViewModel :ViewModel(){
    val zhidata= MutableLiveData<KaiBean>()
    fun getzhi(
        userId:Int,
        sessionId:String,
        liveType:Int,
        liveTitle:String,
        longitude:String,
        latitude:String,
        multipartBody: MultipartBody.Part
    ){
        HttpUtils.httpUtils.server.getzhi(userId, sessionId, liveType, liveTitle, longitude, latitude, multipartBody)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                zhidata.value=it
            }
    }
    val kandata=MutableLiveData<KanBean>()
    fun getkan(
        userId:Int,
        sessionId:String,
        liveId:Int,
    ){
        HttpUtils.httpUtils.server.getkan(userId, sessionId, liveId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                kandata.value=it
            }
    }
    val livedata=MutableLiveData<LiveBean>()
    fun getlive(
    ){
        HttpUtils.httpUtils.server.getlive()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                livedata.value=it
            }
    }
    val chodata=MutableLiveData<ChoBean>()
    fun getpay(
        totalPrice :Int,
    ){
        HttpUtils.httpUtils.server2.getpay(totalPrice)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                chodata.value=it
            }
    }

}